package cn.shopifymall.io;

import org.junit.Test;

import java.io.FileInputStream;

/**
 * @Author 孤风雪影
 * @Email gitee.com/efairy520
 * @Date 2025/1/22 18:53
 * @Version 1.0
 */
public class FileInputStream_ {

    @Test
    public void readFile() throws Exception {
        String filePath = "E:\\news1.txt";
        int readLenth = 0;
        //缓冲区，一次读取最多8个字节
        byte[] buffer = new byte[8];
        FileInputStream fileInputStream = new FileInputStream(filePath);
        while ((readLenth = fileInputStream.read(buffer)) != -1) {
            System.out.print(new String(buffer, 0, readLenth));
        }
    }
}
